﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using HYRevitCode.CurveUtility;
using YJKRGeometry;

namespace QuickModel.InteractiveOperation
{
	public class CurveInfo : CurveCadElement
	{
		public Category RevitLayer { get; set; }

		public CurveInfo(Curve curve, string layerName = null)
		{
			this.ThisCurve = curve;
			this.UseLayerName = layerName;
			this.BoundingBoxCurve = new List<Curve>();
			this.BoundingBoxCurve.Add(curve);
		}

		public override bool IfIntersection(CurveCadElement inputCurve)
		{
			bool result;
			try
			{
				XYZ xyz = null;
				result = CurveUtilityMethod.TryGetIntersectionPoint(this.ThisCurve, inputCurve.ThisCurve, out xyz);
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		public override bool IfParallel(CurveCadElement inputCurve)
		{
			bool result;
			try
			{
				bool flag = inputCurve.ThisCurve is Line && this.ThisCurve is Line;
				if (flag)
				{
					Line line = this.ThisCurve as Line;
					Line line2 = inputCurve.ThisCurve as Line;
					XYZ direction = line.Direction;
					XYZ direction2 = line2.Direction;
					result = Geometry.IsParallel(direction, direction2);
				}
				else
				{
					result = false;
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}
	}
}
